package com.aplink.generic.constant.type;

public enum ActionType {

    AUTO_SYNC(0xF10020, "AutoSync"),
    CHANGE_PASSWORD(0xF10020, "ChangePassword"),
    CHECK_EXISTS(0xF10016, "CheckExists"),
    CLEAR_FORM(0xF10021, "ClearAll"),
    CLOSE(0xF10018, "Close"),
    DELETE(0xF10007, "Delete"),
    DOWNLOAD(0xF10003, "Download"),
    DOWNLOAD_ALL(0xF10017, "DownloadAll"),
    FORGOT_PASSWORD(0xF10019, "ForgotPassword"),
    INIT_DATA(0xF10002, "InitData"),
    INSERT(0xF10005, "Insert"),
    LOGIN(0xF10001, "Login"),
    LOGIN_OFFLINE(0xF10012, "LoginOffline"),
    LOGOUT(0xF10011, "Logout"),
    NEXT_PAGE(0xF10008, "NextPage"),
    OFFLINE_MODE(0xF10010, "OfflineMode"),
    REFRESH_PAGE(0xF10015, "RefreshPage"),
    RESET_APPLICATION(0xF10009, "ResetApplication"),
    SAVE(0xF10013, "Save"),
    TAKE_PICTURE(0xF10014, "TakePicture"),
    UPDATE(0xF10006, "Update"),
    UPLOAD(0xF10004, "Upload");
    public static ActionType get(final int code) {
        for (final ActionType actionType : ActionType.values()) {
            if (actionType.getCode() == code) {
                return actionType;
            }
        }
        return null;
    }

    public static ActionType get(final String value) {
        for (final ActionType actionType : ActionType.values()) {
            if (actionType.getValue().equalsIgnoreCase(value)) {
                return actionType;
            }
        }
        return null;
    }

    private int mCode;

    private String mValue;

    private ActionType(final int code, final String value) {
        this.mCode = code;
        this.mValue = value;
    }

    public int getCode() {
        return this.mCode;
    }

    public String getValue() {
        return this.mValue;
    }
}
